package com.example.appbarlayoutdemo.base;

import android.app.Application;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;

/**
 * @author: njb
 * @date: 2020/3/24 0024 11:17
 * @desc:
 */
public class App extends Application {
    private static Context sContext;
    private static App instance;

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        sContext = getApplicationContext();
        //设置APP应用字体不缩放
        initconfig();
    }



    private void initconfig() {
        Resources res = super.getResources();
        Configuration config = new Configuration();
        config.setToDefaults();
        res.updateConfiguration(config, res.getDisplayMetrics());
    }



    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
    }

    //单例模式中获取唯一的MyApplication实例
    public static App getInstance() {
        return instance;
    }

    public static Context getContext() {
        return sContext;
    }
}
